<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true" CodeFile="Branch.aspx.cs" Inherits="Admin_Branch" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <span style="font-size: 32pt"><strong>Branches Manager</strong></span><br />
    <br />
    <asp:Label ID="Label1" runat="server" ForeColor="Red"></asp:Label><br />
    <table style="width: 359px">
        <tr>
            <td style="width: 87px" rowspan="2">
                Branch's name:</td>
            <td style="width: 100px" rowspan="2">
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
                    ErrorMessage="Branch's name cannot be blank" Width="194px" Display="Dynamic"></asp:RequiredFieldValidator></td>
        </tr>
        <tr>
        </tr>
        <tr>
            <td style="width: 87px" rowspan="2">
                Address:</td>
            <td style="width: 100px" rowspan="2">
                <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox2"
                    ErrorMessage="Address cannot be blank" Width="155px" Display="Dynamic"></asp:RequiredFieldValidator></td>
        </tr>
        <tr>
        </tr>
        <tr>
            <td style="width: 87px">
                PinCode:</td>
            <td style="width: 100px">
                <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1"
                    DataTextField="Pincode" DataValueField="Pincode">
                </asp:DropDownList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Con %>"
                    SelectCommand="SELECT [Pincode] FROM [Area]"></asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <asp:Button ID="Button1" runat="server" Text="Add new branch" OnClick="Button1_Click" /></td>
        </tr>
    </table>
    <br />
    <strong><span style="font-size: 16pt">List of branches:</span></strong><br />
    <br />
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="BranchId"
        DataSourceID="SqlDataSource2" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black" GridLines="Vertical">
        <Columns>
            <asp:BoundField DataField="BranchId" HeaderText="BranchId" InsertVisible="False"
                ReadOnly="True" SortExpression="BranchId" />
            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
            <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
            <asp:BoundField DataField="PinCode" HeaderText="PinCode" SortExpression="PinCode" />
            <asp:CommandField ShowEditButton="True" />
            <asp:CommandField ShowDeleteButton="True" />
        </Columns>
        <FooterStyle BackColor="#CCCCCC" />
        <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="#CCCCCC" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:Con %>"
        DeleteCommand="DELETE FROM [Branch] WHERE [BranchId] = @BranchId" InsertCommand="INSERT INTO [Branch] ([Name], [Address], [PinCode]) VALUES (@Name, @Address, @PinCode)"
        SelectCommand="SELECT * FROM [Branch]" UpdateCommand="UPDATE [Branch] SET [Name] = @Name, [Address] = @Address, [PinCode] = @PinCode WHERE [BranchId] = @BranchId">
        <DeleteParameters>
            <asp:Parameter Name="BranchId" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="Address" Type="String" />
            <asp:Parameter Name="PinCode" Type="Int32" />
            <asp:Parameter Name="BranchId" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="Address" Type="String" />
            <asp:Parameter Name="PinCode" Type="Int32" />
        </InsertParameters>
    </asp:SqlDataSource>
</asp:Content>

